<template>
	<view class="main">
		<view>扫描二维码</view>
		<view>
			 <input type="text" v-model="scanVal" readonly/>
			 <image @click="scan" src="/static/img/scan.png" style="width: 50px;height: 50px;"></image>
		</view> 
		<view @click="changhe">横屏竖屏</view>
		<view> </view> 
		<view>生成二维码</view>
		<view class="" style="height:140px;" @click="save()">
		 	 <qrcode val="address" style="padding: 0px;" :size="130" ref="qrcode"></qrcode>
		 </view>
		 <view>复制文本</view>
		 <view @click="copyData('http://www.ip.cn')"> http://www.ip.cn </view> 
	</view>
	
</template>
 <script>
	 /*
	  像UI官网一样去收集各种组件
	  select 
	  抽屉
	  弹出层
	  
	 */
	import qrcode from '@/components/Myqrcode/qrcode.vue'
   export default {
	   	  components:{qrcode},
            data() {
                return {
                    "scanVal":"",
					 hp:false,
                }
            },
			onNavigationBarButtonTap(e) {
				console.log(e)
				 uni.navigateTo({
				 	url:'/pages/comment/list'
				 })
			},
			mounted() {
					var that = this
					setTimeout(function() { that.$refs.qrcode.creatQrcode() }, 1)
			},
			methods:{
				save(){
					 this.saveQrcode(this.$refs.qrcode.img)
				},
				scan(){
					  var that = this 
					  uni.scanCode({
						success:function(res){
							console.log(JSON.stringify(res));
							that.scanVal  = res.result
						}
					  })
				},
				changhe(){
					this.hp = !this.hp;
					plus.screen.lockOrientation(this.hp?'landscape-primary':'portrait-primary');  
				 	
				}
			}
     }
 </script>
<style> 
.main{
	padding: 10px;
}
</style>

